package leetcode.code0257;

import java.util.ArrayList;
import java.util.List;

import leetcode.IDebug;
import leetcode.helper.tree.TreeNode;

public class Solution implements IDebug {

	List<String> ans;

	public List<String> binaryTreePaths(TreeNode root) {
		ans = new ArrayList<>();
		StringBuffer sb = new StringBuffer();
		this.binaryTreePaths(root, sb);
		return ans;
	}

	private void binaryTreePaths(TreeNode root, StringBuffer sb) {
		sb.append(root.val);
		if (root.left == null && root.right == null) {
			ans.add(sb.toString());
			return;
		}
		sb.append("->");
		if (root.left != null) {
			this.binaryTreePaths(root.left, new StringBuffer(sb));
		}

		if (root.right != null) {
			this.binaryTreePaths(root.right, new StringBuffer(sb));
		}

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
